#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void
z_to_pi(const long n, const int *z, int *pi)
{
	int i = 1;

	while (i < n) {
		if (z[i] > pi[i + z[i] - 1])
			pi[i + z[i] - 1] = z[i];
		i++;
	}
	i--;
	while (i > 0) {
		if (pi[i - 1] < pi[i] - 1)
			pi[i - 1] = pi[i] - 1;
		i--;
	}

	if (pi[0]) fprintf(stderr, "pi[0] != 0\n");
}

int
main(void)
{
	long n;
	int *z, *pi;
	int i = 0;

	scanf("%ld", &n);
	z  = (int *) calloc(n, sizeof *z);
	pi = (int *) calloc(n, sizeof *pi);
	while (i < n) {
		scanf("%d", z + i);
		++i;
	}

	z_to_pi(n, z, pi);

	for (i = 0; i < n; ++i) printf("%d ", pi[i]);
	putchar('\n');

	free(z);
	free(pi);

	return 0;
}
